{extend name="../../base/view/common/base" /}
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">工作汇报</h3>
	{if condition="$id eq 0"}
	<table class="layui-table">
		<tr>
			<td class="layui-td-gray">接收人<font>*</font></td>
			<td>
				<input type="text" name="person_name" value="" lay-verify="required" lay-reqText="请选择接收人" placeholder="请选择接收人" readonly class="layui-input picker-more">
				<input type="hidden" name="uids" value="">
			</td>
			<td class="layui-td-gray">汇报类型</td>
			<td>
				{eq name="$type" value="1"}日报{/eq}
				{eq name="$type" value="2"}周报{/eq}
				{eq name="$type" value="3"}月报{/eq}
			</td>
		</tr>
		{if condition="($type == 1)"}
		<tr>
			<td class="layui-td-gray">今日工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入今日工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入今日工作内容"></textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">明日计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入明日计划" class="layui-textarea" style="height: 120px;"></textarea>
			</td>
		</tr>
		{elseif condition="($type == 2)"}
		<tr>
			<td class="layui-td-gray">本周工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入本周工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入本周工作内容"></textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">下周计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入下周计划" class="layui-textarea" style="height: 120px;"></textarea>
			</td>
		</tr>
		{elseif condition="($type == 3)"}
		<tr>
			<td class="layui-td-gray">本月工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入本月工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入本月工作内容"></textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">下月计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入下月计划" class="layui-textarea" style="height: 120px;"></textarea>
			</td>
		</tr>
		{/if}
		<tr><td class="layui-td-gray">其它事项</td>
			<td colspan="3">
				<textarea name="remark" placeholder="请输入其它事项" class="layui-textarea" style="height: 120px;"></textarea>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray"><div class="layui-input-inline">附件</div> <div class="layui-input-inline"><button type="button" class="layui-btn layui-btn-xs" id="upFile"><i class="layui-icon"></i></button></div></td>
			<td colspan="3" style="line-height:inherit">
				<div class="layui-row" id="fileList">
					<input type="hidden" data-type="file" name="file_ids" value="">
				</div>
			</td>
		</tr>
	</table>
	<div style="padding:10px 0;">
		<input type="hidden" value="{$id}" name="id">
		<input type="hidden" value="{$type}" name="type">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即发送</button>
	</div>
	{else/}
	<table class="layui-table">
		<tr>
			<td class="layui-td-gray">接收人</td>
			<td>
				{$detail.person_name}
			</td>
			<td class="layui-td-gray">汇报类型</td>
			<td>
				{eq name="$detail.type" value="1"}日报{/eq}
				{eq name="$detail.type" value="2"}周报{/eq}
				{eq name="$detail.type" value="3"}月报{/eq}
			</td>
		</tr>
		{if condition="($type == 1)"}
		<tr>
			<td class="layui-td-gray">今日工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入今日工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入今日工作内容">{$detail.works}</textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">明日计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入明日计划" class="layui-textarea" style="height: 120px;">{$detail.plans}</textarea>
			</td>
		</tr>
		{elseif condition="($type == 2)"}
		<tr>
			<td class="layui-td-gray">本周工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入本周工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入本周工作内容">{$detail.works}</textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">下周计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入下周计划" class="layui-textarea" style="height: 120px;">{$detail.plans}</textarea>
			</td>
		</tr>
		{elseif condition="($type == 3)"}
		<tr>
			<td class="layui-td-gray">本月工作<font>*</font></td>
			<td colspan="3">
				<textarea name="works" placeholder="请输入本月工作内容" class="layui-textarea" style="height: 120px;" lay-verify="required" lay-reqText="请输入本月工作内容">{$detail.works}</textarea>
			</td>
		</tr>
		<tr><td class="layui-td-gray">下月计划</td>
			<td colspan="3">
				<textarea name="plans" placeholder="请输入下月计划" class="layui-textarea" style="height: 120px;">{$detail.plans}</textarea>
			</td>
		</tr>
		{/if}
		<tr><td class="layui-td-gray">其它事项</td>
			<td colspan="3">
				<textarea name="remark" placeholder="请输入其它事项" class="layui-textarea" style="height: 120px;">{$detail.remark}</textarea>
			</td>
		</tr>
		<tr>
			<td class="layui-td-gray"><div class="layui-input-inline">附件</div> <div class="layui-input-inline"><button type="button" class="layui-btn layui-btn-xs" id="upFile"><i class="layui-icon"></i></button></div></td>
			<td colspan="3" style="line-height:inherit">
				<div class="layui-row" id="fileList">
					<input type="hidden" name="file_ids" data-type="file" value="{$detail.file_ids}">
					{notempty name="$file_array"}
					{volist name="file_array" id="vo"}
					<div class="layui-col-md4" id="uploadImg{$vo.id}">{:file_card($vo)}</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>
	</table>
	<div style="padding:10px 0;">
		<input type="hidden" value="{$id}" name="id">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform1">提交保存</button>
	</div>
	{/if}
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool','employeepicker','oaTool'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,  oaTool = layui.oaTool;
		oaTool.addFile({
			btn: 'upFile',
			box: 'fileList'
		});	
		//监听发送
		form.on('submit(webform)', function(data){
			if(data.field.uids==login_admin){
				layer.msg('接收人不能是自己');
				return false;
			}
			$.ajax({
				url: "/oa/work/send",
				type:'post',
				data:data.field,
				success:function(e){
					layer.msg(e.msg);
					if (e.code == 0) {						
						setTimeout(function(){
							parent.location.reload();
						},1000);
					}
				}
			})
			return false;
		});
		
		//监听保存
		form.on('submit(webform1)', function(data){
			$.ajax({
				url: "/oa/work/add",
				type:'post',
				data:data.field,
				success:function(e){
					layer.msg(e.msg);
					if (e.code == 0) {						
						setTimeout(function(){
							parent.location.reload();
						},1000);
					}
				}
			})
			return false;
		});

	}		
	</script>
{/block}
<!-- /脚本 -->